<template>
  <div class="numbox">
    <button :disabled="count === 0" class="minus" @click="minus">-</button>
    <input type="text" :value="count">
    <button class="plus" @click="plus">+</button>
  </div>
</template>

<script>
export default {
  props: ['count'],
  methods: {
    plus () {
      this.$emit('send', this.count + 1)
    },
    minus () {
      this.$emit('send', this.count - 1)
    }
  }
}
</script>

<style lang="less">
.numbox {
  position: relative;
  display: inline-block;
  width: 120px;
  height: 35px;
  padding: 0 40px;
  overflow: hidden;
  vertical-align: top;
  vertical-align: middle;
  background-color: #efeff4;
  border: solid 1px #bbb;
  border-radius: 3px;
  button {
    position: absolute;
    top: 0;
    width: 40px;
    height: 100%;
    padding: 0;
    overflow: hidden;
    font-size: 18px;
    font-weight: 400;
    line-height: 100%;
    color: #555;
    background-color: #f9f9f9;
    border: none;
    border-radius: 0;
    outline: none;
    &:active {
      background-color: #ccc;
    }
  }
  .minus{
    left: 0;
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
  }
  .minus:disabled {
    color: silver;
  }
  input {
    display: inline-block;
    width: 100%!important;
    height: 100%;
    padding: 0 3px!important;
    margin: 0;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    word-break: normal;
    border: none!important;
    border-right: solid 1px #ccc!important;
    border-left: solid 1px #ccc!important;
    border-radius: 0!important;
    outline: none;
  }
  .plus {
    right: 0;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px
  }
}
</style>
